package com.yupi.springbootinit.controller;

import com.yupi.springbootinit.common.BaseResponse;
import com.yupi.springbootinit.common.ResultUtils;
import com.yupi.springbootinit.manager.AIManager;
import com.yupi.springbootinit.model.dto.AI.AIRequest;
import com.yupi.springbootinit.model.vo.AIResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@ResponseBody
@RequestMapping("/AI")
@Slf4j
public class AiController {

    @Resource
    private AIManager aiManager;

    @PostMapping
    public BaseResponse<AIResponse> getAI(@RequestBody AIRequest aiRequest){
        String message = aiManager.sendMsgToXingHuoAI(false, aiRequest.getMessage());
        log.info("AI: " + message);
        AIResponse aiResponse = new AIResponse();
        aiResponse.setAIMessage(message);
        return ResultUtils.success(aiResponse);
    }
}
